import path from 'path'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import Components from 'unplugin-vue-components/vite'
import glob from 'fast-glob'

export default defineConfig(async ({ mode }) => {
  const env = loadEnv(mode, process.cwd(), '')

  return {
    resolve: {
      alias: [
        // {
        //   find: /^xtdi-ui\/components$/,
        //   replacement: path.resolve(`../packages/xtdi-ui/components`, 'index.js')
        // },
        {
          find: /^xtdi-ui$/,
          replacement: path.resolve('../packages/xtdi-ui', 'index.js')
        }
      ]
    },
    server: {
      host: true,
      https: !!env.HTTPS
    },
    plugins: [vue(), vueJsx()],
    optimizeDeps: {
      include: ['vue', '@vue/shared']
    }
  }
})
